{extend name='public/layout' /}
{block name='content'}
<style>
    #ask-con *{vertical-align: top;}
</style>
<div class="main m_t_15">
    <div class="position"><p>您当前的位置：<a href="{:url('Index/index')}">{$site.title}</a> > <a href="{:url('store/index')}">店铺</a>&gt;{$title} </p></div>
    <div class="overflow_h m_t_15">
        <div class="agent_left">
            <div class="agent_info con-box">
                <div class="info_head">
                    {include file='store/userinfo' /}
                </div>
                <div class="n_h_n3_l m_t_15">
                    <div class="n_h_n3_t">
                        {include file='store/nav' /}
                    </div>

                    <div class="news_h_box">
                        <div class="boker_ask01">
                            <form action="{:url('Ajax/question')}" id="info_form"  method="post">
                                <div class="ask_list_r01">
                                    <p>问题标题：<input type="text" style="width:80%;" class="inp07" name="title" id="title" placeholder="请输入标题" /></p>
                                    <p id="ask-con">问题描述：<textarea name="content" class="inp08" style="width:80%;" id="content" placeholder="请在这输入问题详细内容描述"></textarea></p>
                                    <p class="overflow_h">问题分类：
  <select class="select03" name="cate_id" id="cate_id">
      {volist name='askCate' id='val'}
      <option value="{$val.id}" {present name="val._child"}disabled{/present}>{$val.name}</option>
      {present name='val._child'}
      {volist name='val._child' id='vo'}
      <option value="{$vo.id}">--{$vo.name}</option>
      {/volist}
      {/present}
      {/volist}
  </select>
</p>
                                    <input type="hidden" name="answer_user_id" value="{$user.id}">
                                    <p>联系姓名：<input type="text" class="inp07" name="user_name" value="{$userInfo.nickname}" id="user_name" /></p>
                                    <p>联系电话：<input class="inp07" type="text" name="phone" id="phone" value="{$userInfo.mobile}"/></p>
                                    <p><a  href="javascript:;" id="askBut" class="but14">提交问题</a></p>
                                </div>
                            </form>
                        </div>

                        <div class="boker_ask02">
                            <h1 class="n_h_title"><span class="s_bg_line">{$user.nickname}回答过的问题 </span></h1>
                            <div class="index_ul03">
                                    {volist name="lists" id='data'}
                                    <dl class="dl_p overflow_h border-bottom">
                                        <dt><img src="__IMG__/loading.gif" class="lazy" data-original="{$data.user.headimgurl}" width="50" height="50" /></dt>
                                        <dd class="dl01"><i class="text11">{$data.ask.title}</i><span>{:date("Y-m-d H:i:s",$data['create_time'])}</span></dd>
                                        <dd class="dl02"><a href="{:url('Question/detail',['id'=>$data['id']])}" target="_blank">{$data.content}</a></dd>

                                    </dl>
                                    {/volist}
                                <div class="plastic_bottom_pages">
                                    {$pages}
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="house_r">
            {include file='store/right'/}

        </div>
    </div>
</div>
<script src="__PUBLIC__/js/layer/layer.js"></script>
<script src="__PUBLIC__/js/plugins/jquery.ajax.form.js"></script>
<script>
    $(function(){
        $('#askBut').bind('click',function(){
            var title = $('#title').val();
            var content = $('#content').val();
            var cate_id = $('#cate_id').val(),username = $('#user_name').val(),phone=$('#phone').val(),reg=/^1[34578][0-9]{9}$/;
            if(cate_id==0){
                layer.msg('请选择分类',{icon:2});
                return false;
            }
            if(title.length==0){
                layer.msg('请填写标题',{icon:2});
                return false;
            }
            if(content.length==0){
                layer.msg('请填写内容',{icon:2});
                return false;
            }

            if(username.length == 0){
                layer.msg('请填写姓名',{icon:2});
                return false;
            }
            if(!reg.test(phone)){
                layer.msg('请填写正确的手机号码',{icon:2});
                return false;
            }
            $('#info_form').submit();
        });
        $('#info_form').ajaxForm({success:complate,dataType:'json'});
        function complate(result){
            if(result.status == 1){
                layer.msg(result.msg,{icon:1});
                setTimeout(function(){
                    window.location.href = location.href + '?t='+Math.random();
                },3000);
            } else {
                layer.msg(result.msg,{icon:2});
            }
        }
    });
</script>
{/block}